package com.hst.capacity.infra.persistence.jpa.vehicle;

import com.hst.capacity.domain.model.entity.driver.DriverCarEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface DriverCarRepository extends JpaRepository<DriverCarEntity, String>, JpaSpecificationExecutor<DriverCarEntity> {

    /**
     * 查找司机车辆信息
     * @param idDriverCar
     * @return
     */
    DriverCarEntity findByIdDriverCar(String idDriverCar);

    /**
     * 根据司机ID查找司机车辆信息
     * @param idDriver
     * @return
     */
    List<DriverCarEntity> findByIdDriver(String idDriver);

    /**
     * 删除司机绑定信息
     * @param idDriverCar
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Modifying
    int deleteByIdDriverCar(String idDriverCar);

}
